package com.example.vo.res;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import com.example.constants.SuccessCodeEnum;

@ApiModel
public class JsonResult {
    @ApiModelProperty(value = "状态码", example = "40001", required = true, position = -2)
    private String code;
    @ApiModelProperty(value = "返回消息", example = "恭喜，成功！", required = true, position = -1)
    private String msg;
    @ApiModelProperty(value = "具体数据")
    private Object data;

    public JsonResult() {
        this.setCode(SuccessCodeEnum.SUCCESS);
        this.setMsg(SuccessCodeEnum.SUCCESS.msg());
    }

    public JsonResult(SuccessCodeEnum code) {
        this.setCode(code);
        this.setMsg(code.msg());
    }

    public JsonResult(SuccessCodeEnum code, String message) {
        this.setCode(code);
        this.setMsg(message);
    }

    public JsonResult(SuccessCodeEnum code, String message, Object data) {
        this.setCode(code);
        this.setMsg(message);
        this.setData(data);
    }

    public JsonResult(SuccessCodeEnum code, Object data) {
        this.setCode(code);
        this.setMsg(code.msg());
        this.setData(data);
    }

    public String getCode() {
        return code;
    }

    public void setCode(SuccessCodeEnum code) {
        this.code = code.val();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
